package cn.cdeden.system.dubbo;

import cn.cdeden.common.core.utils.MapstructUtils;
import cn.cdeden.system.api.RemotePostService;
import cn.cdeden.system.api.domain.vo.RemoteJobVo;
import cn.cdeden.system.api.domain.vo.RemotePostVo;
import cn.cdeden.system.domain.vo.SysJobVo;
import cn.cdeden.system.domain.vo.SysPostVo;
import cn.cdeden.system.service.ISysPostService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
@DubboService
public class RemotePostServiceImpl implements RemotePostService {

    private final ISysPostService sysPostService;

    /**
     *根据用户id查询该用户所有的岗位
     * @param userId
     * @return
     */
    @Override
    public List<Long> getAllJobById(Long userId) {
//        List<Long> longs = sysPostService.selectPostListByUserId(userId);
//        List<SysJobVo> job = sysPostService.getAllJobById(userId);
        return sysPostService.selectPostListByUserId(userId);
    }

    @Override
    public RemoteJobVo getById(Long jobId) {
        SysPostVo sysPostVo = sysPostService.selectPostById(jobId);
        return MapstructUtils.convert(sysPostVo, RemoteJobVo.class);
    }

    @Override
    public List<RemoteJobVo> selectUserJobByUserId(Long userId) {
        return MapstructUtils.convert(sysPostService.selectUserJobByUserId(userId), RemoteJobVo.class);
    }
}
